﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter8.Section6
{
    public class Example06
    {
        public Example06()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double, double, double, double> fxy
                = new V.Function.ToLastType<double, double, double, double>(dxdy);

            V.Function.ToLastType<double, double, double, double> fyz
              = new V.Function.ToLastType<double, double, double, double>(dydz);

            V.Function.ToLastType<double, double, double, double> fzx
              = new V.Function.ToLastType<double, double, double, double>(dzdx);


            V.Function.ToLastType<double[], double[]> ff
              = new V.Function.ToLastType<double[], double[]>(surface);
            V.Surface s = new V.Surface(ff);
            s.Parameter1StartValue = 0.0;
            s.Parameter1EndValue = Math.PI / 2.0;
            s.Parameter2StartValue = 0.0;
            s.Parameter2EndValue = 2.0 * Math.PI;

            V.IntegralOf2Form obj = new V.IntegralOf2Form(fxy, fyz, fzx, s);
            obj.Compute();

            result += obj.Result.ToString() + "\r\n";

            result += (Math.PI / 2.0).ToString() + "\r\n";
        }
        private double[] surface(double[] u)
        {
            double[] x = new double[3];
            x[0] = Math.Sin(u[0]) * Math.Cos(u[1]);
            x[1] = Math.Sin(u[0]) * Math.Sin(u[1]);
            x[2] = Math.Cos(u[0]);
            return x;
        }
        private double dxdy(double x, double y, double z)
        {
            return z * z;
        }
        private double dydz(double x, double y, double z)
        {
            return 0.0;
        }
        private double dzdx(double x, double y, double z)
        {
            return 0.0;
        }
    }
}
/*
1.57082483509655
1.5707963267949
*/

